package zjh_20230329;

import java.io.*;

public class practise01 {
    public static void main(String[] args) {
        File soursefile = new File("C:\\out.txt");
        File newfile = new File("D:\\kaifamiao\\" + soursefile.getName());
        try (FileInputStream fileInputStream = new FileInputStream(soursefile);
             FileOutputStream fileOutputStream = new FileOutputStream(newfile);) {

//            int size = fileInputStream.readAllBytes().length;
//            System.out.println(size);

            byte[] bytes = new byte[1024];
            int length = 0;
            while ((length = fileInputStream.read(bytes)) > 0) {
                fileOutputStream.write(bytes, 0, length);
            }
            System.out.println("已完成");
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
